
set matsize 11000
set more off

cd \Data

********************************************************************************
** This do file produces the regression results displayed in Table A10 and Figure
** A4 which test for a discontinuity in household income across homes built
** before vs. after Title 24 was implemented.
********************************************************************************


use premise_characteristics.dta, clear
keep if (zoning == "R-1" | zoning == "RD 1" | zoning == "RD 2" | zoning == "RD 3" | zoning == "RD 4" | zoning == "RD 5" | zoning == "RD-1" | zoning == "RD-2" | zoning == "RD-3" | zoning == "RD-4" | zoning == "RD-5" | zoning == "RD1" | zoning == "RD2" | zoning == "RD3" | zoning == "RD4" | zoning == "RD5" | zoning == "RD5PD")

gen year_bin = 1
forvalues i = 2/36 {
	replace year_bin = `i' if year_built >= 1940 + (`i' - 2)*2 & year_built <= 1941 + (`i'-2)*2
}
replace year_bin = 37 if year_built > 2009
tab year_bin, gen(y)

gen years_pre = min(max(year_built - 1978, -10), 0)
gen years_post = max(min(year_built - 1978, 10), 0)
gen post = 0
replace post = 1 if year_built >= 1978

collapse (sum) y1-y37 (max) max_year = year_built (min) min_year = year_built (mean) year_built years_pre years_post post (mean) income, by(block_group)
egen total = rowtotal(y1-y37)
forvalues i = 1/37 {
	replace y`i' = y`i'/total
}

gen diff = year_built - 1978

********************************************************************************
** Table A10: Testing for discontinuity in income.
** Note: the first model allows different trends pre/post. The second model
** assumes constant trend.

reg mean_income post years_pre years_post if min_year>=1970 & max_year<=1987, robust
reg mean_income post years_pre years_post if min_year>=1968 & max_year<=1989, robust
reg mean_income post years_pre years_post if min_year>=1966 & max_year<=1991, robust

reg mean_income post diff if min_year>=1970 & max_year<=1987, robust
reg mean_income post diff if min_year>=1968 & max_year<=1989, robust
reg mean_income post diff if min_year>=1966 & max_year<=1991, robust


********************************************************************************
** Figure A4: Average income by vintage of home

reg mean_income y1-y37, noc robust
